<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>邮箱历史</h2>
    </div>


    <ul class="tab-nav nav">

        <li><a href="{:U('Admin/Addons/adminList',array('name'=>'Mail'))}">邮件配置</a></li>
        <li><a href="{:addons_url('Mail://Mail/mailList')}">邮箱列表</a></li>
        <li><a href="{:addons_url('Mail://Mail/sendEmail')}">发送邮件</a></li>
        <li class="current"><a href="{:addons_url('Mail://Mail/history')}">邮件历史</a></li>

    </ul>



    <php>
        foreach($searches as $search){
        if($_REQUEST[$search['name']])
        {
        $show=1;
        }
        }
    </php>

    <div style="margin-bottom: 10px;" <eq name='show' value="">class="hidden" </eq>id="search_form">

    <style>
        .tb_search td{
            padding: 5px 10px;
        }
    </style>
    <form id="searchForm" method="post" action="{:addons_url('Mail://Mail/history')}" class="form-dont-clear-url-param">
        <div class="search-form  cf " style="margin-bottom: 10px">
            <table class="tb_search">


                    <tr style="line-height: 28px">
                        <td>
                           邮件标题
                        </td>
                        <td>
                            <input style="float: none" type="text" name="title" class="search-input"
                                   value="{:I('title')}">
                        </td>

                    </tr>

                <tr><td></td>
                    <td><input type="submit" class="btn" value="确定"/> <button class="btn ajax-post btn" onclick="toggle_search()">关闭</button></td>
                    <td></td>
                </tr>
            </table>
        </div>
    </form>
    <div style="border-top:1px solid #ccc;border-bottom: 1px solid white"></div>
    </div>
    <!-- 按钮工具栏 -->
    <div class="cf">
        <div class="fl">

            <button class="btn submit-btn" url="?status=-1" target-form="ids" style="padding: 6px 16px;" onclick="toggle_search()">搜索</button>

            <button class="btn ajax-post btn" url="{:addons_url('Mail://Mail/setStatus',array('status'=>-1))}" target-form="ids">删除</button>

        </div>
    </div>



    <form action="{:addons_url('Mail://Mail/sendEmail')}" method="post">

        <div class="data-table table-striped">
            <table>
                <thead>
                <tr>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">
                    </th>
                    <th>ID</th>
                    <th>标题</th>
                    <th>邮件内容</th>
                    <th>寄件人</th>
                    <th>创建时间</th>
                </tr>
                </thead>
                <tbody>
                <notempty name="mailList">
                    <volist name="mailList" id="vo">


                        <tr>
                            <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$vo.id}"></td>
                            <td>{$vo.id}</td>
                            <td><a href="{:addons_url('Mail://Mail/mailDetail',array('id'=>$vo['id']))}">{$vo.title}</a></td>
                            <td>{$vo.body}</td>
                            <td>{$vo.from}</td>
                            <td>{$vo.create_time|friendlyDate}</td>

                        </tr>


                    </volist>
                    <else/>
                    <td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
                </tbody>
            </table>

        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        function toggle_search(){
            $('#search_form').toggle('slide');
        }
        $(function(){


            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
                query = query.replace(/^&/g,'');
                if( url.indexOf('?')>0 ){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e){
                if(e.keyCode === 13){
                    $("#search").click();
                    return false;
                }
            });

        });
    </script>
</block>